/*************************************************************************
	> File Name: fork_exit.c
	> Author: Angel Criss
	> Blog: blog.abbycin.tk 
	> Created Time: Mon 07 Jul 2014 02:41:03 PM CST
 ************************************************************************/

#include"head.h"

void exit_1(void)
{
    printf("this is exit_1\n");
}
void exit_2(void)
{
    printf("this is exit_2\n");
}

int main(int argc,char *argv[])
{
            sleep(2);
            atexit(exit_1);
            atexit(exit_2); // a little bit like stack, first in lost out,\
            for the first registed function has more primary work to do\
                so do it int the end
    /*pid_t child;
    switch(child=fork()){
        case -1:
            err("fork");
            break;
        case 0:
            printf("child will exit in a while\n");
            sleep(2);
            atexit(exit_1);
            atexit(exit_2);
        default:
            printf("parent will exit in a while too\n");
            sleep(2);
            atexit(exit_2);
    }
    */
}
